Skip to content

Recognise top-level JSON-LD in Operation.process_json#17

Merged
namedgraph merged 2 commits into
mainfrom
feat-top-level-json-ld
Jun 15, 2026
Merged

Recognise top-level JSON-LD in Operation.process_json#17
namedgraph merged 2 commits into
mainfrom
feat-top-level-json-ld

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Summary

  • Operation.process_json now parses a top-level dict carrying any JSON-LD reserved key (@context, @graph, @id, @type) into an rdflib.Graph, ahead of the existing generic-dict recursion. Symmetric with the bare-value auto-wrap (json_to_rdflib): a JSON scalar becomes a Literal; a JSON-LD object becomes a Graph.
  • Previously every consuming op (POST, PUT, Merge, ldh-CreateItem, ldh-CreateContainer, the ldh-Add* family) re-parsed the same JSON-LD payload in its own execute_json. The runtime treated bare JSON-LD as opaque JSON to recurse into; only the ops at the boundary knew its semantics.
  • Unblocks the chat-extraction use case in AutoGraph: an LLM that emits JSON-LD as its final answer (image-extracted structured metadata) now gets a real Graph result the renderer can lay out — instead of a dict of Literals that renders as raw text.
  • Version bumped to 1.3.0.

Test plan

  • Existing unit suite — uv run pytest tests/unit -q → 96 passed, 0 failed.
  • Smoke trace — a bare JSON-LD dict (@context + @graph describing a schema:Car) handed to Operation.process_json now returns an rdflib.Graph with the expected triple count, instead of a dict.
  • Once tagged and consumed by AutoGraph, end-to-end chat verification: an LLM emitting structured JSON-LD as its final answer renders as a structured per-subject view via render_graph.

🤖 Generated with Claude Code

namedgraph and others added 2 commits June 15, 2026 15:17
A dict carrying any JSON-LD reserved key (@context, @graph, @id,
@type) is now parsed to an rdflib.Graph by Operation.process_json
itself, ahead of the existing generic-dict recursion. Previously
every consuming op (POST, PUT, Merge, ldh-Create*/Add*) re-parsed
the same JSON-LD payload in its own execute_json — the runtime
treated bare JSON-LD as opaque JSON to recurse into, only the ops
at the boundary knew its semantics.

Symmetric with the bare-value auto-wrap (json_to_rdflib): a JSON
scalar becomes a Literal, a JSON-LD object becomes a Graph.

Unblocks the chat-extraction case: an LLM that emits JSON-LD as
its final answer (image metadata, structured extraction) gets a
real Graph result the renderer can lay out, rather than a dict of
Literals that renders as raw text.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@namedgraph namedgraph merged commit ab4a4eb into main Jun 15, 2026
6 checks passed
@namedgraph namedgraph deleted the feat-top-level-json-ld branch June 15, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant